object dmDadosRelat: TdmDadosRelat
  OldCreateOrder = False
  Left = 421
  Top = 130
  Height = 392
  Width = 530
  object sqlFaturamento: TSQLDataSet
    SchemaName = 'root'
    CommandText = 
      'select nfsdtemis, '#13#10#13#10'(select sum(nfsvldesc)'#13#10'from tblnfs nfs1'#13#10 +
      'where nfs1.nfstip = 0'#13#10'and nfs1.nfsdtemis = tblnfs.nfsdtemis) as' +
      ' vldesctip0,'#13#10#13#10'(select  sum(nfsvltotnf)'#13#10'from tblnfs nfs1'#13#10'wher' +
      'e nfs1.nfstip = 0'#13#10'and nfs1.nfsdtemis = tblnfs.nfsdtemis) as vlt' +
      'otnftip0,'#13#10#13#10'(select sum(nfsvldesc)'#13#10'from tblnfs nfs1'#13#10'where nfs' +
      '1.nfstip = 1'#13#10'and nfs1.nfsdtemis = tblnfs.nfsdtemis) as vldescti' +
      'p1,'#13#10#13#10'(select  sum(nfsvltotnf)'#13#10'from tblnfs nfs1'#13#10'where nfs1.nf' +
      'stip = 1'#13#10'and nfs1.nfsdtemis = tblnfs.nfsdtemis) as vltotnftip1,' +
      #13#10#13#10'sum(nfsvldesc) as nfsvldesc, sum(nfsvltotnf) as nfsvltotnf'#13#10 +
      #13#10'from tblnfs'#13#10'where tblnfs.nfsdtemis between :nfsdtini and :nfs' +
      'dtfim'#13#10'group by nfsdtemis'#13#10'order by nfsdtemis'
    DbxCommandType = 'Dbx.SQL'
    MaxBlobSize = -1
    Params = <
      item
        DataType = ftDate
        Name = 'nfsdtini'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'nfsdtfim'
        ParamType = ptInput
      end>
    SQLConnection = dmConexao.SQLConnection
    Left = 80
    Top = 32
    object sqlFaturamentonfsdtemis: TDateField
      FieldName = 'nfsdtemis'
      Required = True
    end
    object sqlFaturamentovldesctip0: TFMTBCDField
      FieldName = 'vldesctip0'
      Precision = 32
      Size = 2
    end
    object sqlFaturamentovltotnftip0: TFMTBCDField
      FieldName = 'vltotnftip0'
      Precision = 32
      Size = 2
    end
    object sqlFaturamentovldesctip1: TFMTBCDField
      FieldName = 'vldesctip1'
      Precision = 32
      Size = 2
    end
    object sqlFaturamentovltotnftip1: TFMTBCDField
      FieldName = 'vltotnftip1'
      Precision = 32
      Size = 2
    end
    object sqlFaturamentonfsvldesc: TFMTBCDField
      FieldName = 'nfsvldesc'
      Precision = 32
      Size = 2
    end
    object sqlFaturamentonfsvltotnf: TFMTBCDField
      FieldName = 'nfsvltotnf'
      Precision = 32
      Size = 2
    end
  end
  object cdsCabecalho: TClientDataSet
    Aggregates = <>
    Params = <>
    Left = 176
    Top = 32
    object cdsCabecalhoSubTitulo: TStringField
      FieldName = 'SubTitulo'
      Size = 255
    end
  end
  object sqlItensVendidos: TSQLDataSet
    SchemaName = 'root'
    CommandText = 
      '/*O SQL EST'#193' NO C'#211'DIGO FONTE*/ '#13#10'select tblins.procod, tblpro.pr' +
      'odescr,'#13#10'           sum(tblins.insqtde) as qtdetot,'#13#10'           ' +
      'sum(tblins.insvltot) as vltot'#13#10'from tblnfs, tblins, tblpro'#13#10'wher' +
      'e tblnfs.nfscod = tblins.nfscod'#13#10'and tblnfs.nfsserie = tblins.nf' +
      'sserie'#13#10'and tblins.procod = tblpro.procod'#13#10'and tblnfs.nfsdtemis ' +
      'between '#39'2012-11-01'#39' and '#39'2012-11-01'#39#13#10'group by 1,2'#13#10'order by 3 ' +
      'desc'#13#10'limit 10'
    DbxCommandType = 'Dbx.SQL'
    MaxBlobSize = -1
    Params = <>
    SQLConnection = dmConexao.SQLConnection
    Left = 288
    Top = 32
    object sqlItensVendidosprocod: TIntegerField
      FieldName = 'procod'
      Required = True
    end
    object sqlItensVendidosprodescr: TStringField
      FieldName = 'prodescr'
      Required = True
      Size = 50
    end
    object sqlItensVendidosqtdetot: TFMTBCDField
      FieldName = 'qtdetot'
      Precision = 32
      Size = 0
    end
    object sqlItensVendidosvltot: TFMTBCDField
      FieldName = 'vltot'
      Precision = 32
      Size = 2
    end
  end
  object sqlEstoque: TSQLDataSet
    CommandText = 
      'select procod, prodescr, proqtdeest,'#13#10'          (proqtdeest * pr' +
      'ovlunit) as vltotestcompra,'#13#10'          (proqtdeest * provlprven)' +
      ' as vltotestvenda'#13#10'from tblpro'#13#10'where proqtdeest > 0'#13#10'order by p' +
      'rodescr'
    DbxCommandType = 'Dbx.SQL'
    MaxBlobSize = -1
    Params = <>
    SQLConnection = dmConexao.SQLConnection
    Left = 80
    Top = 104
    object sqlEstoqueprocod: TIntegerField
      FieldName = 'procod'
      Required = True
    end
    object sqlEstoqueprodescr: TStringField
      FieldName = 'prodescr'
      Required = True
      Size = 50
    end
    object sqlEstoqueproqtdeest: TIntegerField
      FieldName = 'proqtdeest'
      Required = True
    end
    object sqlEstoquevltotestcompra: TFMTBCDField
      FieldName = 'vltotestcompra'
      Required = True
      Precision = 24
      Size = 2
    end
    object sqlEstoquevltotestvenda: TFMTBCDField
      FieldName = 'vltotestvenda'
      Required = True
      Precision = 24
      Size = 2
    end
  end
  object sqlFaturamentoItem: TSQLDataSet
    SchemaName = 'root'
    CommandText = 
      'select tblins.procod,'#13#10'       tblpro.prodescr,'#13#10'       sum(tblin' +
      's.insqtde) as qtde,'#13#10'       sum(tblins.insqtde * tblpro.provluni' +
      't) as vlcompra,'#13#10'       round(sum(tblins.insvltot - (tblins.insv' +
      'ltot * ((tblnfs.nfsvldesc * 100) / (tblnfs.nfsvltotnf + tblnfs.n' +
      'fsvldesc)/100))),2) as vlvenda'#13#10'  from tblnfs, tblins, tblpro, t' +
      'blfap'#13#10'where tblnfs.nfscod = tblins.nfscod'#13#10'    and tblnfs.nfsse' +
      'rie = tblins.nfsserie'#13#10'    and tblins.procod = tblpro.procod'#13#10'  ' +
      '  and tblpro.fapcod = tblfap.fapcod'#13#10'    and tblnfs.nfsdtemis be' +
      'tween :nfsdtini and :nfsdtfim'#13#10'group by 1,2'
    DbxCommandType = 'Dbx.SQL'
    MaxBlobSize = -1
    Params = <
      item
        DataType = ftUnknown
        Name = 'nfsdtini'
        ParamType = ptInput
      end
      item
        DataType = ftUnknown
        Name = 'nfsdtfim'
        ParamType = ptInput
      end>
    SQLConnection = dmConexao.SQLConnection
    Left = 160
    Top = 200
  end
  object dspFaturamentoItem: TDataSetProvider
    DataSet = sqlFaturamentoItem
    Left = 160
    Top = 248
  end
  object cdsFaturamentoItem: TClientDataSet
    Aggregates = <>
    Params = <
      item
        DataType = ftDate
        Name = 'nfsdtini'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'nfsdtfim'
        ParamType = ptInput
      end>
    ProviderName = 'dspFaturamentoItem'
    OnCalcFields = cdsFaturamentoItemCalcFields
    Left = 160
    Top = 296
    object cdsFaturamentoItemprocod: TIntegerField
      FieldName = 'procod'
      Required = True
    end
    object cdsFaturamentoItemprodescr: TStringField
      FieldName = 'prodescr'
      Required = True
      Size = 50
    end
    object cdsFaturamentoItemqtde: TFMTBCDField
      FieldName = 'qtde'
      Precision = 32
      Size = 0
    end
    object cdsFaturamentoItemvlcompra: TFMTBCDField
      FieldName = 'vlcompra'
      Precision = 32
      Size = 2
    end
    object cdsFaturamentoItemvlvenda: TFMTBCDField
      FieldName = 'vlvenda'
      Precision = 32
      Size = 2
    end
    object cdsFaturamentoItemCalcVllucro: TFloatField
      FieldKind = fkInternalCalc
      FieldName = 'CalcVllucro'
    end
    object cdsFaturamentoItemCalcPerclucro: TFloatField
      FieldKind = fkInternalCalc
      FieldName = 'CalcPerclucro'
    end
  end
  object sqlFaturamentoFamilia: TSQLDataSet
    SchemaName = 'root'
    CommandText = 
      'select tblpro.fapcod,'#13#10'       tblfap.fapdescr,'#13#10'       sum(tblin' +
      's.insqtde) as qtdevendida,'#13#10'       sum(tblins.insqtde * tblpro.p' +
      'rovlunit) as vltotcompra,'#13#10'       round(sum(tblins.insvltot - (t' +
      'blins.insvltot * ((tblnfs.nfsvldesc * 100) / (tblnfs.nfsvltotnf ' +
      '+ tblnfs.nfsvldesc)/100))),2) as vltotvenda'#13#10'   from tblnfs, tbl' +
      'ins, tblpro, tblfap'#13#10'where tblnfs.nfscod = tblins.nfscod'#13#10'    an' +
      'd tblnfs.nfsserie = tblins.nfsserie'#13#10'    and tblins.procod = tbl' +
      'pro.procod'#13#10'    and tblpro.fapcod = tblfap.fapcod'#13#10'    and tblnf' +
      's.nfsdtemis between :nfsdtini and :nfsdtfim'#13#10'group by 1,2'
    DbxCommandType = 'Dbx.SQL'
    MaxBlobSize = -1
    Params = <
      item
        DataType = ftDate
        Name = 'nfsdtini'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'nfsdtfim'
        ParamType = ptInput
      end>
    SQLConnection = dmConexao.SQLConnection
    Left = 280
    Top = 200
  end
  object dspFaturamentoFamilia: TDataSetProvider
    DataSet = sqlFaturamentoFamilia
    Left = 280
    Top = 248
  end
  object cdsFaturamentoFamilia: TClientDataSet
    Aggregates = <>
    Params = <
      item
        DataType = ftDate
        Name = 'nfsdtini'
        ParamType = ptInput
      end
      item
        DataType = ftDate
        Name = 'nfsdtfim'
        ParamType = ptInput
      end>
    ProviderName = 'dspFaturamentoFamilia'
    OnCalcFields = cdsFaturamentoFamiliaCalcFields
    Left = 280
    Top = 296
    object cdsFaturamentoFamiliafapcod: TIntegerField
      FieldName = 'fapcod'
      Required = True
    end
    object cdsFaturamentoFamiliafapdescr: TStringField
      FieldName = 'fapdescr'
      Required = True
      Size = 45
    end
    object cdsFaturamentoFamiliaqtdevendida: TFMTBCDField
      FieldName = 'qtdevendida'
      Precision = 32
      Size = 0
    end
    object cdsFaturamentoFamiliavltotcompra: TFMTBCDField
      FieldName = 'vltotcompra'
      Precision = 32
      Size = 2
    end
    object cdsFaturamentoFamiliavltotvenda: TFMTBCDField
      FieldName = 'vltotvenda'
      Precision = 32
      Size = 2
    end
    object cdsFaturamentoFamiliaCalcVllucro: TFloatField
      FieldKind = fkInternalCalc
      FieldName = 'CalcVllucro'
    end
    object cdsFaturamentoFamiliaCalcPerclucro: TFloatField
      FieldKind = fkInternalCalc
      FieldName = 'CalcPerclucro'
    end
  end
end
